package com.dayuanit.util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class JedisUtil {
	
	private static final String HOST = "192.168.2.161";
	private static final int PORT = 6379;
	
	public static final JedisPool pool;
	
	static {
		//jedis = new Jedis(HOST, PORT);
		JedisPoolConfig config = new JedisPoolConfig();
		pool = new JedisPool(config, HOST);
	}
	
	private JedisUtil() {
		
	}
	
	public static Jedis getJedis() {
		Jedis jedis = null;
		for (int i=0;i<100;i++) {
			jedis = pool.getResource();
			if (null != jedis) {
				break;
			}
		}
		return jedis;
	}
	
}
